package com.powernode.spring6.service;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component("logAspect")
@Aspect
public class LogAspect {
    @Before("execution(* com.powernode.spring6.service.UserService.*(..))")
    public void before(){
        System.out.println("前置通知");
    }

    @AfterReturning("execution(* com.powernode.spring6.service.UserService.*(..))")
    public void afterreturning(){
        System.out.println("后置通知");
    }

    @Around("execution(* com.powernode.spring6.service.UserService.*(..))")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前环绕");

        joinPoint.proceed();

        System.out.println("后环绕");
    }

    @After("execution(* com.powernode.spring6.service.UserService.*(..))")
    public void after(){
        System.out.println("最终通知");
    }
}
